<template>
	<view>
		<view class="topBox">
		<head-navbar :back="true" class="headNavbar" :bgColor="'#FE5900'">
			<view>
				<text style="color: #FFFFFF;">我的预售</text>
			</view>
			<view class="rightTip" slot="right" @click="openHeaderMenu" data-type="0" style="display: flex;align-items: center;">
				<view style="color: #FFFFFF;font-size: 26upx;">取消列表</view>
				<image class="img" src="../../../static/img/down.png"></image>
				<view class="paoBox" v-show="box">
					<view class="paopao"></view>
					<view class="list" @click="toPage(0,'/pages/my/sale/sale?type=4')">取消列表</view>
					<view class="list" @click="toPage(0,'/pages/my/sale/sale?type=5')">自用列表</view>
					<view class="list" style="border: none;" @click="toPage(0,'/pages/my/sale/sale?type=3')">已下架列表</view>
				</view>
			</view>
		</head-navbar>
		<view class="tabBar">
			<u-tabs  class="Uswiper" ref="uTabs" :list="list" :current="current" @change="tabsChange" active-color="#FE5900" :is-scroll="false"  font-size="30" height="90" bar-width="60"></u-tabs>
			<view class="manger" v-show="current == 1" @click="toManger">管理</view>
		</view>
		</view>
				<OrderComponent class="son" :height="height"  v-if='current == 0' ref="orderCom"></OrderComponent>
				<groupComponent class="son" :height="height" v-else ref="groupCom"></groupComponent>
		</swiper>
	</view>
</template>

<script>
	import * as api from '@/api/order/index.js';
	import {getMygoods} from '@/api/user/index.js';
	import OrderComponent from './OrderComponent'
	import groupComponent from './groupComponent'
	export default {
		components:{
			OrderComponent,
			groupComponent
		},
		data() {
			return {
              box:false,
			  join:false,
			  height:0,
			  list: [{
			  	name: '综合'
			  }, {
			  	name: '分组'
			  }],
			  goodlist:[],
			  // 因为内部的滑动机制限制，请将tabs组件和swiper组件的current用不同变量赋值
			  current: 0, // tabs组件的current值，表示当前活动的tab选项
			  swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
			}
		},
		onLoad(optiopn) {
		},
		onshow() {
			console.log(123)
		},
		onReady(){
			let that = this
			uni.getSystemInfo({
				success: function(res) { // res - 各种参数
					let info = uni.createSelectorQuery().select(".topBox");
					info.boundingClientRect(function(data) { //data - 各种参数
						that.height = res.windowHeight - data.height
					}).exec()
				}
			});
		},
		methods: {
			async getMySaleList() {
				try{
					let parmas = {
						pageSize:20,
						pageNum:1,
						status:1
					}
					const ret = await getMygoods(parmas);
					this.goodlist = ret.data.obj.list;
					if(res.data.obj.length < this.pageSize){
						this.status = 'nomore'
					}
				}catch(error){
					console.log(error)
				}
			},
			toManger(){
				console.log(123)
				uni.navigateTo({
					url:'/pages/my/preSale/manger'
				})
			},
			openHeaderMenu(){
				this.box = !this.box
			},
			// tabs通知swiper切换
			tabsChange(index) {
				this.current = index;
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			// scroll-view到底部加载更多
			onreachBottom() {
				
			},
			onswiperchange(){}
		}
	}
</script>

<style lang="scss">
	@import './index.scss';
</style>
